package com.glodon.paas.account.biz;

import java.util.List;

import org.springframework.security.oauth2.common.OAuth2AccessToken;

import com.glodon.paas.account.dao.domain.AddressEntity;
import com.glodon.paas.account.dao.domain.AvatarEntity;
import com.glodon.paas.account.dao.domain.CompanyEntity;
import com.glodon.paas.account.dao.domain.ConsumerEntity;
import com.glodon.paas.account.dao.domain.ContactEntity;
import com.glodon.paas.account.dao.domain.OAuthTokenEntity;
import com.glodon.paas.account.dao.domain.ScopeEntity;
import com.glodon.paas.account.dao.domain.UserEntity;

public interface UserBiz {
	
	//String insertUser(UserEntity user);
	/**
	 * 注册或激活用户
	 * 
	 */
	UserEntity registerAccount(String accountName,Integer accountType, String password, Integer status);
	
	void updateUser(UserEntity user);
	
	UserEntity getUser(String userId);
	
	List<UserEntity> getUserByIds(String[] userIds);
	
	/**
	 * 
	 * @param AccountName		:email,mobile
	 * @param accountType
	 * @param status
	 * @return
	 */
	UserEntity getUserByAccountName(String account,Integer accountType, Integer status);

	/**
	 * 重置密码	
	 * @param userId			用户id
	 * @param newPassword		新密码
	 * @param authorization		修改密码需要的权限
	 * @param authorizationType	权限类型	 -1不需要权限，1密码
	 */
	void resetPassword(String userId, String newPassword, String authorization, Integer authorizationType);
	/**
	 * 检查权限
	 * @param account		账号：id, loginName, email, mobile...
	 * @param accountType	账号类型账号类型
	 * @param authorization
	 * @param authorizationType
	 * @return
	 */
	boolean checkAuthorization(String account, Integer accountType, String authorization, Integer authorizationType);
	
	List<OAuthTokenEntity> getAccessTokens(String userId);
	
	List<OAuth2AccessToken> getOAuth2Tokens(String userId);
	
	String getConsumerId(OAuth2AccessToken token);
	
	void deleteToken(String tokenId);
	
	AddressEntity getAddress(String addressId);
	
	String insertAddress(AddressEntity addr);
	
	void updateAddress(AddressEntity addr);
	
	ContactEntity getContact(String contactId);
	
	String insertContact(ContactEntity contact);
	
	void updateContact(ContactEntity contact);
	
	CompanyEntity getCompany(String companyId);
	
	String insertCompany(CompanyEntity company);
	
	void updateCompany(CompanyEntity company);
	
	ConsumerEntity getConsumerByKey(String key);
	
	boolean checkEmailExist(String email);

	/**
	 * (id)或者(userId,size)必须输入一组
	 * 
	 * 如果输入了id, 将忽略userId,size
	 * 如果没有输入id，则id = userId_size
	 */
	int saveAvatar(String id, String userId, Integer size, byte[] item);

	/**
	 * 如果输入了id, 将忽略userId,size
	 * 
	 * @param id		头像的id
	 * @param userId
	 * @param size
	 * @return
	 */
	AvatarEntity getAvatar(String id, String userId, Integer size);
	/**
	 * 如果输入了id, 将忽略userId,size
	 */
	int deleteAvatar(String id, String userId, Integer size);

	/**
	 * 激活用户
	 * @param userId
	 * @param accountName	账号名
	 * @param accountType	账号名类型，普通登录名，邮件，手机等
	 * @param password
	 */
	void activeUser(String userId, String accountName,Integer accountType, String password);

    void addProjectRole(String id,String userId, String projectId, String roleId,String orgId);
    
    int deleteProjectRole(String userId, String projectId, String roleId,String orgId);
    int updateProjectRole(String projectId, String oldeRoleId,String newRoleId); 
    
    List<ScopeEntity>  getScope(String scopes);
}
